#include "shell_port.h"
#define USART_UNIT                      (CM_USART2) 
/* 1. 创建shell对象，开辟shell缓冲区 */
Shell shell;
char shell_buffer[512];
/* 2. 自己实现shell写函数 */
signed short User_Shell_Write(char *data, unsigned short len)
{
//	UART_TxNoBlocking(USART_UNIT, data,(uint32_t)len);
//	USART_WriteData(USART_UNIT,(uint16_t)data);
//  Uart1_Send_Bytes((uint8_t *)data,(uint16_t)len);
//    bsp_usart1_transfer_dma(data,(uint32_t)len);
//    bsp_usart1_transfer_wait((uint8_t *)data,(uint32_t)len);
//    for(int i = 0;i<len;i++)
//    {
////        DDL_ConsoleOutputChar(data[i]);
//    }
    bsp_uart_send(&uart2,(uint8_t *)data,len);
  return len;
}
 
/* 3. 自己实现shell读函数 */
signed short User_Shell_Read(char *data, unsigned short len)
{
	*data = 0;
  if(Check_Uart2_Rx_empty() == 0)
  {
    *data = Get_Uart2_Rx_data();
    return 1;//返回1标识数据已经准备OK
  }
	else
	{
		return 0;              //返回0表示数据未准备好
	}

}
 
/* 4. 编写初始化函数 */
void User_Shell_Init(void)
{
    //注册自己实现的读写函数
  shell.write = User_Shell_Write;
  shell.read = User_Shell_Read;
    
    //调用shell初始化函数
  shellInit(&shell, shell_buffer, 512);
}



